\pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\b0\i0\ulnone\fs28\fc0\cf0 Q: The following code snippet is excerpted from a Bourne shell script which attempts to determine how to invoke the C preprocessor on any given UNIX platform. The script creates a file called testcpp.c and runs the C preprocessor on that file redirecting the output to testcpp.out. When I run this script under NEXTSTEP it incorrectly inserts a space in the output file "
\f1\fs24 abc +xyz
\f0\fs28 ". This causes the test which confirms "cc -E" as the correct invocation to fail. Is this a bug in your C preprocessor?\
\
\i \
\f1\i0\fs24\fc1\cf1 : see how we invoke the C preprocessor\
echo " "\
echo "Checking to see how your C preprocessor is invoked..."\
cat <<'EOT' >testcpp.c\
#define ABC abc\
#define XYZ xyz\
ABC+XYZ\
EOT\
echo 'Maybe "cc -E" will work...'\
cc -E testcpp.c >testcpp.out 2>&1\
if $contains 'abc+xyz' testcpp.out >/dev/null 2>&1 ; then\
echo "Yup, it does."\
cpp='cc -E'\
else\
echo 'Nope...maybe "cc -P" will work...'\
cc -P testcpp.c >testcpp.out 2>&1\
if $contains 'abc+xyz' testcpp.out >/dev/null 2>&1 ; then\
echo "Yup, that does."\
\f0\fs28\fc0\cf0 \
A: The space inserted before the "+xyz" follows the behavior specified by ANSI C. If you want the old behavior of standard UNIX compilers, use the
\f1\fs24 -traditional
\f0\fs28 flag. The man page on cc(1) shows a large number of useful compiler flags in addition to
\f1\fs24 -traditional
\f0\fs28 . The flags
\f1\fs24 -bsd
\f0\fs28 and
\f1\fs24 -fwritable-strings
\f0\fs28 may also be needed when compiling old UNIX programs.\